/**
 * zmn文章模块-文章列表
 * 文件命名格式：zmn.模块名称.表名称.功能.jas
 * @author heguanghua
 * @since 2018/10/18
 */
layui.extend({
    zmnExportUtil: '{/}/static/js/zmn.excel.util'
}).define(['index', 'form', 'table', 'laypage', 'layedit', 'zmnExportUtil', 'laydate'], function (exports) {
    var $ = layui.$;
    var form = layui.form;
    var layer = layui.layer;
    var table = layui.table;
    var laypage = layui.laypage;
    var zmnExportUtil =layui.zmnExportUtil;
    table.init('zmn-table', {
        toolbar: "#zmn-table-tool",
        page: true,
        limit: json.pageSize,
        height: 'full-160',
        done: function () {
            $("div[lay-event='LAYTABLE_EXPORT']").attr('lay-event', 'CUSTOM_EXPORT');
        },
    });
    laypage.render(layui.$.extend({limits:[10, 20, 30, 40, 50,100]},zmnPage.laypageOptions(json)));
    var ids = [];

    // 按钮事件
    table.on("toolbar(zmn-table)", function (obj) {
        let items = obj.config.data;
        // ids = zmnPage.layIdsChecked(items, "groupId");

        //导出excel
        if(obj.event=='CUSTOM_EXPORT'){
            zmnExportUtil.doExportExcel('zmn-table','前台产品-分类关联');
            return;
        }

        var ids = new Array();
        for (var k = 0; k < items.length; k++) {
            var o = items[k];
            var isChecked = o["LAY_CHECKED"];
            if (isChecked) {
                ids.push(o['servCategId']+'-'+o['categOneId']+'-'+o['categId']);
            }
        }

        if (obj.event === "delete") {
            if (ids.length === 0) {
                return layer.alert("请选择至少一列！");
            }
            layer.confirm('您确定要删除关联吗？', {
                btn: ['确定', '取消']
            }, function () {
                zmnPage.ajaxSimple("/serv/showCateg/ass/delete.action", {ids: ids.join(",")}, 1000);
            });
        }
    });
    // 分类下拉框联动
    zmnPage.laySelectLinkage(form, "/common/categ/listChildsForShow.action", "categOneId", "categId", null);
    //对外暴露的接口
    exports('art_serv_ass_category_show_list', {});
});

/**
 * 描述: 修改前台分类关联详情页名称
 **/
function modifyDetailName(groupId){
    zmnLayUtil.openIframeCustom(layer, "/serv/showCateg/ass/detail.action?groupId="+groupId, {title: "修改", shade: 0.8, area:["580px", "210px"]});
}
